﻿
if not exists(Select * from sysobjects where name = 'CartItem' and xtype = 'U')
Begin

CREATE TABLE [dbo].[CartItem](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ProductId] [int] NOT NULL,
	[Quantity] [int] NOT NULL,
	[SalePrice] [bigint] NOT NULL,
	[IsArchived] [bit] NOT NULL,
	[CartId] [int] NOT NULL,
	[Discount] [int] NOT NULL,
	[DiscountTypeId] [int] NOT NULL,
	[ShippingTypeId] [int] NOT NULL,
	[CreationDate] [datetime] NOT NULL,
	[LastUpdate] [datetime] NOT NULL,
	[AllowPartialDelivery] [bit] NOT NULL,
	[RevisionId] [timestamp] NOT NULL,
	[IsLocked] [bit] NOT NULL,
	[OfferName] [varchar](256) NULL,
	[InventoryTimeStateId] [int] NULL,
	[AddFrom] [varchar](100) NULL,
) 

alter table dbo.CartItem add constraint PK_CartItem_Id primary key (Id)

create index IX_CartItem_ProductId on CartItem(ProductId)

End
Go